﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Shop.Domain.NewFolder1;

namespace Shop.Service.LoginService
{
    
    public class LoginService : BaseService
    {
        public List<Shop.Domain.NewFolder1.Administrator1Model> Getlogin(string AdminName, string AdminPassw)
        {
         return   db.Query<Shop.Domain.NewFolder1.Administrator1Model>("select * from Administrator1 where adminName = "+ AdminName + " and adminPassword ="+ AdminPassw).ToList();

        }

        public List<Shop.Models.IndentList> GetIndent()//查询全部表格数据
        {
            return db.Query<Shop.Models.IndentList>(@"select t1.*,t2.zong from (select indentDetail.*,members.membersName from indentDetail inner join members on members.id=indentDetail.order1) as t1
            inner join(select indent1, sum(indent.totalMoney) as zong from indent group by indent.indent1) as t2 on t1.id = t2.indent1").ToList();
        }

        public List<Shop.Models.IndentList> GetIndent(string pars)//带条件查询表格数据
        {
            return db.Query<Shop.Models.IndentList>(@"select t1.*,t2.zong from (select indentDetail.*,members.membersName from indentDetail inner join members on members.id=indentDetail.order1) as t1
            inner join(select indent1, sum(indent.totalMoney) as zong from indent group by indent.indent1) as t2 on t1.id = t2.indent1 where id="+ pars).ToList();
        }

        public Administrator1Model GetAdmin(Administrator1Model s)//同过id查整条信息
        {
            return db.Single<Administrator1Model>(s.Id);
        }

        public void EditAdmin(Administrator1Model dd)
        {
            db.Update(dd);
        }
    }
}
